package com.tangsm.spring.boot.filter.common.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;

/**
 * 请求监听器
 * @author tangsm
 */
public class MyHttpRequestListener implements ServletRequestListener {

    private static final Logger log = LoggerFactory.getLogger(MyHttpRequestListener.class);

    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        log.info("请求监听器，request 监听器被销毁");
    }

    @Override
    public void requestInitialized(ServletRequestEvent sre) {
        HttpServletRequest req = (HttpServletRequest) sre.getServletRequest();
        String requestURI = req.getRequestURI();
        log.info("请求监听器，{} 被调用", requestURI);
    }
}
